package top.hsocode.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import top.hsocode.service.HelloService;

/**
 * HelloController class
 *
 * @author hsowan
 * @date 2018/09/30
 */
@Controller
@RequestMapping(value = "/hello")
public class HelloController {

    @Autowired
    private HelloService helloService;

    @RequestMapping(value = "/dockerweb", method = RequestMethod.GET)
    public ModelAndView count(){
        ModelAndView mv = new ModelAndView();
        int count = helloService.getCount();
        mv.addObject("count", count);
        helloService.saveCount(count + 1);
        mv.setViewName("index");
        return mv;
    }
}
